<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */

    public function up()
    {
        Schema::create('rules', function (Blueprint $table) {
            $table->id();
            $table->integer('pid')->default(0);
            $table->enum('type', ['menu_dir', 'menu', 'button'])->default('menu')->comment('类型:menu_dir=菜单目录,menu=菜单项,button=页面按钮');
            $table->string('title')->nullable()->comment('标题');
            $table->string('name')->nullable()->comment('规则名称');
            $table->string('path')->nullable()->comment('路由路径');
            $table->string('icon')->nullable()->comment('图标');
            $table->enum('menu_type', ['tab', 'link', 'iframe'])->nullable()->comment('菜单类型:tab=选项卡,link=链接,iframe=Iframe');
            $table->string('url')->nullable()->comment('');
            $table->string('component')->nullable()->comment('组件路径');
            $table->tinyInteger('keepalive')->default(0)->comment('缓存:0=关闭,1=开启');
            $table->enum('extend', ['none', 'add_rules_only', 'add_menu_only'])->default('none')->comment('扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单');
            $table->string('remark')->nullable()->comment('备注');
            $table->string('weigh')->nullable()->comment('权重');
            $table->tinyInteger('status')->default(1)->comment('状态:0=禁用,1=启用');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('rules');
    }
};
